package org.jctc.els.modules.biz.controller.permissions;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.AllArgsConstructor;
import org.jctc.els.modules.biz.service.permissions.IPermissionsService;
import org.jctc.els.modules.biz.entity.permissions.Permissions;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 权限表 前端控制器
 * </p>
 *
 * @author lyh
 * @since 2021-02-26
 */
@Api(tags = {"权限表"})
@RestController
@AllArgsConstructor
@RequestMapping("/permissions")
public class PermissionsController {

    private IPermissionsService permissionsService;


    @ApiOperation(value = "新增权限表")
    @PostMapping()
    public boolean save(@RequestBody Permissions permissions){
        return permissionsService.save(permissions);
    }

    @ApiOperation(value = "删除权限表")
    @DeleteMapping("{id}")
    public boolean remove(@PathVariable("id") Long id){
        return permissionsService.remove(id);
    }

    @ApiOperation(value = "更新权限表")
    @PutMapping()
    public boolean edit(@RequestBody Permissions permissions){
        return permissionsService.edit(permissions);
    }

    @ApiOperation(value = "查询权限表分页数据")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "pageNum", value = "页码"),
        @ApiImplicitParam(name = "pageSize", value = "每页条数")
    })
    @GetMapping()
    public Page<Permissions> selectListByPage(@RequestParam(value = "pageNum") Integer pageNum,
                                   @RequestParam(value = "pageSize") Integer pageSize){
        return permissionsService.selectListByPage(pageNum, pageSize);
    }

    @ApiOperation(value = "根据id查询权限表")
    @GetMapping("{id}")
    public Permissions selectById(@PathVariable("id") Long id){
        return permissionsService.selectById(id);
    }

}
